(defvar *lsp-list* '("index"))
(defvar *page-list* '(index))

;;;use to restart an existing site
(defun init-website-dir (path)
  (load-website-dir path)
  (dolist (lsp *lsp-list*)
    (compile-file (format nil "~a/~a.lisp" path lsp))
    (load (format nil "~a/~a.abcl" path lsp))))

;;;remove an existing lsp name
(defun remove-lsp (lsp)
  (setf *lsp-list* (delete lsp *lsp-list* :test #'equalp)))
;;;rename an existing lsp name
(defun rename-lsp (lsp to)
  (setf *lsp-list* (substitute to lsp *lsp-list* :test #'equalp)))
;;;remove an existing page function name
(defun remove-page (page)
  (setf *page-list* (delete page *page-list*)))
;;;rename an existing page function name
(defun rename-page (page to)
  (setf *page-list* (substitute to page *page-list*)))
;;;if lsp exists in *lsp-list*
(defun has-lsp (lsp)
  (if (member lsp *lsp-list*)
      (return-from has-lsp t)
      (return-from has-lsp nil)))
;;;if page function exists in *page-list*
(defun has-page (page)
  (if (member page *page-list*)
      (return-from has-page t)
      (return-from has-page nil)))
;;;push a page function name to *page-list*
(defun publish-page (page)
  (if (has-page page) () (push page *page-list*)))
;;;push a lsp name to *lsp-list*
(defun publish-lsp (lsp)
  (if (has-lsp lsp ) () (push lsp *lsp-list*))) 
;;;save *page-list* and *lsp-list* to file
(defun flush-website-dir (path)
  (save-website-dir path))
(defun save-website-dir (path)
  (save-lsp-list path)
  (save-page-list path))

(defun save-lsp-list (path)
  (with-open-file (out (format nil "~a/~a" path "lsp-list")
		       :direction :output
		       :if-exists :supersede)
    (with-standard-io-syntax
      (print *lsp-list* out))))
(defun save-page-list (path)
  (with-open-file (out (format nil "~a/~a" path "page-list")
		       :direction :output
		       :if-exists :supersede)
    (with-standard-io-syntax
      (print *page-list* out))))
;;;load *page-list* and *lsp-list* from file
(defun load-website-dir (path)
  (load-lsp-list path)
  (load-page-list path))
(defun load-lsp-list (path)
   (with-open-file (in (format nil "~a/~a" path "lsp-list"))
    (with-standard-io-syntax
      (setf *lsp-list* (read in)))))
(defun load-page-list (path)
   (with-open-file (in (format nil "~a/~a" path "page-list"))
    (with-standard-io-syntax
      (setf *page-list* (read in)))))  


  